package pojo;

import client502test.DTXMLOT;
import client502test.DTXMLOTRET;
import client502test.SIOT2SAPSENDER;
import client502test.SIOT2SAPSENDERService;

import java.net.Authenticator;
import java.util.UUID;


public class XmlDao {

	private static final String LANGUAGE_ZH = "ZH"; // 中文 
	private static final String LANGUAGE_EN = "EN"; // 英文
	private static final String LANGUAGE_TH = "TH"; // 泰文 
	
	private String DEFAULT_ZXMLDT = "AMOEBA";
	private String DEFAULT_ZYLFD2 = LANGUAGE_ZH; // 默认语言版本为中文
	
	public String retrieveData(String zsysid, String zintno, String zxmldt, String zylfd1, String zylfd2) {
		
		Authenticator.setDefault(new MyAuthentication());
		SIOT2SAPSENDERService service = new SIOT2SAPSENDERService();
		SIOT2SAPSENDER sender = service.getHTTPPort();
		DTXMLOT param = new DTXMLOT();
		param.setZSYSID(zsysid); // "AMB"
		param.setZINTNO(zintno); // "INT_AMB010"
		param.setZXMLDT(null == zxmldt?DEFAULT_ZXMLDT:zxmldt); 
		if(null == zylfd1) {
			zylfd1 = UUID.randomUUID().toString().replace("-","");
		}
		param.setZYLFD1(zylfd1);
		param.setZYLFD2(null == zylfd2?DEFAULT_ZYLFD2:zylfd2);
		DTXMLOTRET result = sender.siOT2SAPSENDER(param);
		
		return result.getZXMLDT();
	}
	
	public static void main(String[] args) {
		String zylfd1 = UUID.randomUUID().toString().replace("-","");
		System.out.println(zylfd1);
	}
	
}
